import java.util.Scanner;

/**
 * A front facing method to interact with a heap
 * @author Matt Dye
 *
 */
public class Printer 
{
	
	@SuppressWarnings("unchecked")
	public static void main(String[] args)
	{
		Boolean done = false;
		Scanner scanner = new Scanner(System.in);
		System.out.println("Type  add to add a print job ,  remove to remove a " +
				"print job , quit  to exit the program , or help  to display this message .");
		System.out.println("Enter the printer type ( GT / Simple )");
		String type = scanner.nextLine();
		if(type.equalsIgnoreCase("Simple"))
		{
			String choice = null;
			String name;
			String pages;		
			@SuppressWarnings("rawtypes")
			Heap heap = new Heap();
			while(!done)
			{
				System.out.println("Enter next command:");
				choice = scanner.nextLine();
				if(choice.equalsIgnoreCase("add"))
				{
					System.out.println("Enter the name of the print job:");
					name = scanner.nextLine();
					System.out.println("Enter the number of pages in the print job");
					pages = scanner.nextLine();
					heap.add(new SimplePrintJob(name,Integer.parseInt(pages)));
					System.out.println("Print queue now contains "+ heap.size() + " job(s)");
				}
				else if(choice.equalsIgnoreCase("remove"))
					{
						System.out.println(heap.remove());
						System.out.println(" "+ heap.size() + " job(s) remaining.");
					}
				else if(choice.equalsIgnoreCase("help"))
				{
					System.out.println("Type  add to add a print job ,  remove to remove a " +
					"print job , quit  to exit the program , or help  to display this message .");
				}
				else if(choice.equalsIgnoreCase("exit"))
					System.exit(0);
			}

		}
		else if(type.equalsIgnoreCase("GT"))
		{
			String choice = null;
			String rank;
			String name;
			String pages;
			int rankNum;
			@SuppressWarnings("rawtypes")
			Heap heap = new Heap();
			while(!done)
			{
				System.out.println("Enter next command");
				choice = scanner.nextLine();
				if(choice.equalsIgnoreCase("add"))
				{
					System.out.println("Enter the name of the print job:");
					name = scanner.nextLine();
					System.out.println("Enter the number of pages in the print job");
					pages = scanner.nextLine();
					System.out.println("Enter the priority ( Dean / Professor / TA )");
					rank = scanner.nextLine();
					
					if(rank.equalsIgnoreCase("Dean"))
					{
						rankNum = 2;
					}
					else if(rank.equalsIgnoreCase("Professor"))
					{
						rankNum = 1;
					}
					else
						rankNum = 0;
					
					heap.add(new GTPrintJob(name,Integer.parseInt(pages),rankNum));
					System.out.println("Print queue now contains "+ heap.size() + " job(s)");
					
				}
				else if(choice.equalsIgnoreCase("remove"))
					{
						System.out.println(heap.remove());
						System.out.println(" "+ heap.size() + " job(s) remaining.");
					}
				else if(choice.equalsIgnoreCase("help"))
				{
					System.out.println("Type  add to add a print job ,  remove to remove a " +
					"print job , quit  to exit the program , or help  to display this message .");
				}
				else if(choice.equalsIgnoreCase("exit"))
					{
						System.exit(0);
					}
			}
			
			
		}
	}
}
